<?php
    class Catalog_category extends Model {
        function __construct() {
            parent::Model();
            $this->load->library('Tree', array('table' => 'tree'));
        }

        function getChildCategories($id) {
            $query = $this->db->where('parent_id', $id)
	            ->where('active', 1)
	            ->where('type_id', 2)
	            ->get('tree');
	        if($query->num_rows() > 0) {
	            return $query->result_array();
	        }

	        return FALSE;
        }

        function getAllCategories() {
            $query = $this->db->where('active', 1)
            ->where('type_id', 2)
            ->get('tree');
            if($query->num_rows() > 0) {
                return $query->result_array();
            }

            return FALSE;
        }
    }
?>